package com.go.ssm.web.exception;

import java.io.PrintStream;
import java.io.PrintWriter;

public class BaseRuntimeException extends RuntimeException {
	private static final long serialVersionUID = 1L;
	private String errorCode;

	public BaseRuntimeException(String errorCode, Throwable e) {
		super(e);
		this.errorCode = errorCode;
	}

	public BaseRuntimeException(String errorCode) {
		this.errorCode = errorCode;
	}

	public BaseRuntimeException(Throwable e) {
		super(e);
	}

	@Override
	public void printStackTrace(PrintStream ps) {
		if (getCause() == null) {
			super.printStackTrace(ps);
		} else {
			ps.println(this);
			getCause().printStackTrace(ps);
		}
	}

	@Override
	public void printStackTrace(PrintWriter pw) {
		if (getCause() == null) {
			super.printStackTrace(pw);
		} else {
			pw.println(this);
			getCause().printStackTrace(pw);
		}
	}

	public String getErrorCode() {
		return this.errorCode;
	}
}
